package com.peng._05weibo.config;

import com.peng._05weibo.common.interceptor.MyInterceptor;
import com.peng._05weibo.common.interceptor.UserLoginInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author peng
 * @Date 2024-04-28 14:19
 */
@Configuration
@Slf4j
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptor())
                .addPathPatterns("/v1/weibo/**")
                .excludePathPatterns("/v1/comment/selectByWeiboId");

        registry.addInterceptor(new UserLoginInterceptor())
                .addPathPatterns("/v1/weibo/insert","v1/comment/insert");
    }
}
